# -*- coding: utf-8 -*-
"""
@Time ： 2021/8/4 22:38
@Auth ： Mr.掌心 2929184523
@Company ：特斯汀学院 @testingedu.com.cn
@Function ：请输入模块功能描述
"""
"""
Android APP分类
1.H5 APP ：安卓壳   ------》  selenium
2.混合型APP：appium+selenium
3.native app : appium
"""



# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
from time import sleep

from appium import webdriver

caps = {}
caps["platformName"] = "Android"
caps["platformVersion"] = "6.0.0"
caps["appPackage"] = "com.lqr.wechat"
caps["appActivity"] = "com.lqr.wechat.activity.SplashActivity"
caps["ensureWebviewsHavePages"] = True


driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
driver.implicitly_wait(15)

el1 = driver.find_element_by_id("com.lqr.wechat:id/btnLogin")
el1.click()
driver.find_elements_by_id('com.tencent.mm:id/cns')[3].click()
el2 = driver.find_element_by_id("com.lqr.wechat:id/etPhone")
el2.send_keys("dawa")
el3 = driver.find_element_by_id("com.lqr.wechat:id/etPwd")
el3.send_keys("123456")
el4 = driver.find_element_by_id("com.lqr.wechat:id/btnLogin")
el4.click()
el5 = driver.find_element_by_id("com.lqr.wechat:id/tvContactsTextNormal")
el5.click()
el6 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.TextView")
el6.click()
el7 = driver.find_element_by_id("com.lqr.wechat:id/btnCheat")
el7.click()
el8 = driver.find_element_by_id("com.android.packageinstaller:id/permission_allow_button")
el8.click()
el9 = driver.find_element_by_id("com.android.packageinstaller:id/permission_allow_button")
el9.click()
el10 = driver.find_element_by_id("com.lqr.wechat:id/etContent")
el10.send_keys("你大爷")
el11 = driver.find_element_by_id("com.lqr.wechat:id/btnSend")
el11.click()

sleep(3)

driver.quit()